// ts中类与接口：jdk1.8新增静态接口和实现接口
// interface:定义静态的接口及行为
// implemants:实现接口（必须作用域class上）
// https://zhuanlan.zhihu.com/p/39376127

export { }   //确保跟其他实例没有成员冲突


// interface eatAndRun{
//     eat(food:string):void
//     run(distance:number):void
// }

//  class Person implements eatAndRun{
//    eat(food:string):void {
//        console.log(`person eat food ${food}`);

//    }  
//    run(distance:number){
//        console.log(`person run ${distance}`);

//    }
//  }

//  class Animote implements eatAndRun{
//      eat(food:string):void{
//          console.log(`Animote eat food ${food}`);

//      }
//      run(distance:number){
//          console.log(`Animote run ${distance}`);

//      }
//  }

//  接口约定：一个接口约定一个行为，一个主体类去继承多接口
// 约定抽象函数，赋予不同的对象不同的函数（能力）
interface Eat {
    eat(food: string): void
}
interface Run {
    run(distance: number): void
}
// 接口约定：用于应用的类的某一属性或者业务定义
class Person implements Eat, Run {
    eat(food: string): void {
        console.log(`person eat food ${food}`);

    }
    run(distance: number) {
        console.log(`person run ${distance}`);

    }
}

class Animal implements Eat, Run {
    eat(food: string): void {
        console.log(`Animote eat food ${food}`);

    }
    run(distance: number) {
        console.log(`Animote run ${distance}`);

    }
}

const p = new Person()
p.eat('beer')
p.run(200)
const a = new Animal()
a.eat('meat')
a.run(300)
console.log('person',p,'animal',a);